-- Object
-- 物体表
Object = {}
Object.objects = {}

Object.Floor = SimpleObjectCreater(1,"Floor")
function Object.Floor:createFunction(x,y,...)
    local arg = {...}
    return physics.body(EDGE,vec2(arg[1],arg[2]),vec2(arg[3],arg[4]))
end
function Object.Floor:draw()
    pushMatrix()
    translate(self.x,self.y)
    strokeWidth(30.0)
    stroke(Colour.Green)
    fill(Colour.Green)
    local points = self.points
    for j = 1,#points - 1 do
        a = points[j]
        b = points[j+1]
        line(a.x, a.y, b.x, b.y)
    end
    popMatrix()
end
Object.Floor:setParameter({type = STATIC})

Object.Tennis = CircleObjectCreater(1,"Tennis","Project:Tennis","Project:Tennis")
Object.Tennis:setSimpleRadius(15)
Object.Tennis:setParameter({mass = 5,restitution = 0.5,friction = 0.25})
Object.Tennis:addToBackBag(2,9)
function Object.Tennis:createFunction(body,...)
    body:applyTorque((math.random(0,1) * 2 - 1) * 17)
end

Object.BaseBall = CircleObjectCreater(2,"BaseBall","Project:BaseBall","Project:BaseBall")
Object.BaseBall:setSimpleRadius(15)
Object.BaseBall:setParameter({mass = 4,restitution = 0.2,friction = 0.35})
Object.BaseBall:addToBackBag(3,9)
function Object.BaseBall:createFunction(body,...)
    body:applyTorque((math.random(0,1) * 2 - 1) * 17)
end

Object.Fan = RectObjectCreater(3,"Fan","Project:FanN","Project:FanN")
Object.Fan:setParameter({type = STATIC})
Object.Fan:setSimpleSize(47,102)
Object.Fan:setRenderOffset(3,-3)

Object.WoodenBox = RectObjectCreater(4,"WoodenBox","Project:WoodBox","Project:WoodBox")
Object.WoodenBox:setParameter({mass = 10,restitution = 0,friction = 0.5})
Object.WoodenBox:setSimpleSize(94/1.5,88/1.5)
Object.WoodenBox:setRenderOffset(-1,1)
Object.WoodenBox:setRenderSize(_,_,18,14)
Object.WoodenBox:addToBackBag(1,9)


Object.Jet = RectObjectCreater(5,"Jet","Project:Jet","Project:IconJet")
Object.Jet:setParameter({mass = 10,restitution = 0,friction = 0.3})
Object.Jet:setSimpleSize(50,100)
Object.Jet:setRenderOffset(1,1)
Object.Jet:setRenderSize(_,_,-2,2)
Object.Jet:addToBackBag(8,9)
function Object.Jet:createFunction(body,...)
    body:applyForce(vec2(0,40000))
end

Object.TNT = RectObjectCreater(6,"TNT","Project:TNT","Project:TNT")
Object.TNT:setParameter({mass = 10,restitution = 0,friction = 2})
Object.TNT:setSimpleSize(94/1.5,88/1.5)
Object.TNT:setRenderSize(_,_,18,14)
Object.TNT:addToBackBag(4,9)


Object.ice = RectObjectCreater(7,"Ice","Project:ice","Project:ice")
Object.ice:setParameter({mass = 1,restitution = 0,friction = 0.00005})
Object.ice:setSimpleSize(100/1.5,100/1.5)
Object.ice:setRenderOffset(0,0)
Object.ice:addToBackBag(5,9)

Object.rubber = RectObjectCreater(8,"Rubber","Project:RubberN","Project:RubberN")
Object.rubber:setParameter({mass = 3,restitution = 0.55,friction = 2000})
Object.rubber:setSimpleSize(100/1.5,100/1.5)
Object.rubber:setRenderOffset(0,0)
Object.rubber:addToBackBag(6,9)

Object.weight = RectObjectCreater(9,"Weight 1000g","Project:weight","Project:weight")
Object.weight:setParameter({mass = 1,restitution = 0,friction = 0.1})
Object.weight:setSimpleSize(80/1.5,100/1.5)
Object.weight:setRenderOffset(0,0)
Object.weight:addToBackBag(7,9)

Object.Bowling = CircleObjectCreater(10,"Bowling","Project:Bowling","Project:Bowling")
Object.Bowling:setSimpleRadius(30)
Object.Bowling:setParameter({mass = 2,restitution = 0.15,friction = 0.35})
Object.Bowling:addToBackBag(9,9)
function Object.Bowling:createFunction(body,...)
    body:applyTorque((math.random(0,1) * 2 - 1) * 30)
end

Object.nail = Nail(20,"Nail","Project:nail","Project:nail Icon")
Object.nail:addToBackBag(1,8)